package com.hgkj.cloud.base.service.impl;

import com.hgkj.cloud.base.common.PageInfo;
import com.hgkj.cloud.base.dao.TenantNoticesMapper;
import com.hgkj.cloud.base.domain.TenantNotices;
import com.hgkj.cloud.base.service.TenantNoticesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class TenantNoticesServiceImpl implements TenantNoticesService {

    @Autowired
    private TenantNoticesMapper tenantNoticesMapper;

    @Override
    public int deleteByPrimaryKey(Long id) {
        return tenantNoticesMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(TenantNotices record) {
        return tenantNoticesMapper.insert(record);
    }

    @Override
    public int insertSelective(TenantNotices record) {
        return tenantNoticesMapper.insertSelective(record);
    }

    @Override
    public TenantNotices selectByPrimaryKey(Long id) {
        return tenantNoticesMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(TenantNotices record) {
        return tenantNoticesMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(TenantNotices record) {
        return tenantNoticesMapper.updateByPrimaryKey(record);
    }

    @Override
    public Long findNoticeCount(Map<String, Object> map) {
        return tenantNoticesMapper.findNoticeCount(map);
    }

    @Override
    public List<TenantNotices> listNotices(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return tenantNoticesMapper.listNotices(map);
    }

    @Override
    public List<TenantNotices> listUnreadNotices(PageInfo pi, Map<String, Object> map) {
        if(pi != null){
            map.put("currentCount", pi.getCurrentCount());
            map.put("pageSize", pi.getPageSize());
        }
        return tenantNoticesMapper.listUnreadNotices(map);
    }

    @Override
    public Long findUnreadNoticeCount(Map<String, Object> map) {
        return tenantNoticesMapper.findUnreadNoticeCount(map);
    }

    @Override
    public int flagNoticeRead(Long id) {
        return tenantNoticesMapper.flagNoticeRead(id);
    }
}
